/**
 * Created by MadFrog on 2017/7/5.
 */

Ext.namespace("admin.event");

admin.event.statistics = function(panelId, title, iconClz){

    var eventStore = new Ext.data.JsonStore({
        url : "admin/event/findByCon",
        fields : ["id", "name", "description", "eventDate", "startTime",
            "endTime", "location", "maxSeat", "status", "createDate", "updateDate"],
        totalProperty : "total",
        root : "data",
        autoLoad : true,
        listeners : {
            beforeload : function(s){
                s.removeAll();
                Ext.apply(s.baseParams, {
                    keyword : queryField.getValue(),
                    status : statusCombo.getValue()
                });
            }
        }
    });
    var eventSm = new Ext.grid.RowSelectionModel({
        singleSelect : true
    });
    var eventCm = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(), {
        header : "活动名称",
        dataIndex : "name",
        width : 240
    }, {
        header : "活动时间",
        dataIndex : "eventDate",
        renderer : renderTime2Minutes,
        width : 120
    }]);
    var statusCombo = genStatusCombo();
    var queryField = genQueryField();
    var eventGrid = new Ext.grid.GridPanel({
        title : "活动列表",
        flex : 4,
        store : eventStore,
        cm : eventCm,
        sm : eventSm,
        frame : true,
        bbar : genPageBar(eventStore)
    });

    var echartsPanel = new Ext.Panel({
        flex : 7,
        title : title,
        autoLoad : {
            scripts : true,
            url : "admin/statistics/eventPage",
        },
        bodyPadding:5,
        bodyStyle:'background-color:#FFFFFF',//设置面板体的背景色
        autoScroll:true
    });

    return new Ext.Panel({
        id : panelId,
        title : title,
        iconCls : iconClz,
        closable : true,
        layout : "hbox",
        layoutConfig : {
            align : "stretch"
        },
        items : [eventGrid, echartsPanel]
    });

}

registerModule("admin.event.statistics", admin.event.statistics);